package com.parfinex.java.phase1.module2.task10;

/**
 * @Author: Li Jiahui
 * @Date: 2020/10/18 19:54
 * @Version 1.0
 */
public class AnonymousInterfaceTest {
    public static void test(AnonymousInterface ai){
        ai.show();
    }

    public static void main(String[] args) {
        AnonymousInterfaceTest.test(new AnonymousInterface() {
            @Override
            public void show() {
                System.out.println("这里是一个接口的实现类");
            }
        });
        System.out.println("-------------");
        AnonymousInterface ait =new AnonymousInterface() {
            @Override
            public void show() {
                System.out.println("匿名内部类就是这么玩的，虽然你很抽象");
            }
        };
        AnonymousInterfaceTest.test(ait);
        // 从java8开始提出新特性 Lamda 表达式可以简化上述代码，格式为：（参数列表）->{方法体}
        AnonymousInterface ait2 =()-> System.out.println("Lamda表达式原来是如此简单！");
        AnonymousInterfaceTest.test(ait2);

    }
}
